package me.jiatao.wan.di

import android.app.Application
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import me.jiatao.wan.AppConfig
import me.jiatao.wan.data.database.AppDataBase
import javax.inject.Singleton

/**
 * @Author: taojia
 * @CreateDate: 2021/8/24 3:57 下午
 * @Version: 1.0
 * @Description:
 */

@Module
@InstallIn(SingletonComponent::class)
object RoomModule {
    @Provides
    @Singleton
    fun provideAppDataBase(application: Application): AppDataBase {
        return Room
            .databaseBuilder(application, AppDataBase::class.java, AppConfig.DATA_BASE_NAME)
            .fallbackToDestructiveMigration()
            .build()
    }
}
